package com.ctshk.rpc.user.req;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * <p>
 *
 * </p>
 *
 * @author 李新科
 * @date 2021/5/19 20:09
 */
@Data
@ApiModel
public class GeneralSmsCaptchaReq implements Serializable{

    @ApiModelProperty(name="contactMobileAreaCode", value = "聯繫人手機區號")
    @NotBlank(message = "手機區號不能为空")
    private String contactMobileAreaCode;

    @ApiModelProperty(name = "contactNumber", value = "聯絡電話")
    @NotBlank(message = "聯絡電話不能为空")
    @Pattern(regexp = "^[0-9]{8,11}$", message = "手机号必须是纯数字,并且是8到11位")
    private String contactNumber;

    @ApiModelProperty(name = "code", value = "验证码,后端调试用,前段不用传")
    private String code;

    public String getContactMobileAreaCode() {
        return replacePlus(contactMobileAreaCode);
    }

    /**
     * 去除加号
     */
    public String replacePlus(String str) {
        return str.replaceAll("\\+","");
    }
}
